home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / gravity.swf / scripts / frame_103 / PlaceObject2_81_18 / CLIPACTIONRECORD onClipEvent(enterFrame).as next >
Encoding:
Text File  |  2007-03-28  |  4.4 KB  |  190 lines

  1. onClipEvent(enterFrame){
  2.    function rotate(rvar)
  3.    {
  4.       _rotation = _rotation + 3 * rvar;
  5.       if(_rotation < 0)
  6.       {
  7.          myRotation = 360 + _rotation;
  8.       }
  9.       else
  10.       {
  11.          myRotation = _rotation;
  12.       }
  13.    }
  14.    function constant()
  15.    {
  16.       myXMomentum += myXMovement - myXGravity;
  17.       myYMomentum += myYMovement - myYGravity;
  18.       if(this._x + myXMomentum >= 480 || 120 >= this._x + myXMomentum)
  19.       {
  20.          _parent.foreground._x -= myXMomentum;
  21.          Xparticleshift = myXMomentum;
  22.       }
  23.       else
  24.       {
  25.          this._x += myXMomentum;
  26.          Xparticleshift = 0;
  27.       }
  28.       if(this._y + myYMomentum >= 280 || 120 >= this._y + myYMomentum)
  29.       {
  30.          _parent.foreground._y -= myYMomentum;
  31.          Yparticleshift = myYMomentum;
  32.       }
  33.       else
  34.       {
  35.          this._y += myYMomentum;
  36.          Yparticleshift = 0;
  37.       }
  38.    }
  39.    function arrowcolour()
  40.    {
  41.       myDistance = Math.sqrt(Math.pow(_this._x - _parent.foreground._x,2) + Math.pow(_this._y - _parent.foreground._y,2));
  42.    }
  43.    function explode()
  44.    {
  45.       if(60 >= i)
  46.       {
  47.          duplicateMovieClip(_parent.particle,"mcc" + i,16384 + i);
  48.          _parent["mcc" + i].myGocommand = "blow";
  49.          i++;
  50.          blowdelay++;
  51.          if(i >= 20)
  52.          {
  53.             this.gotoAndStop(2);
  54.          }
  55.       }
  56.    }
  57.    function engineburn()
  58.    {
  59.       if(myPartAmount >= i)
  60.       {
  61.          duplicateMovieClip(_parent.particle,"mc" + i,16384 + i);
  62.          _parent["mc" + i].myGocommand = "go";
  63.          _parent["mc" + i]._x = _X;
  64.          _parent["mc" + i]._y = _Y;
  65.          i++;
  66.       }
  67.       else
  68.       {
  69.          i = 0;
  70.       }
  71.    }
  72.    function gravity()
  73.    {
  74.       origin_x = _root.foreground._x;
  75.       origin_y = _root.foreground._y;
  76.       mouse_x = this._x;
  77.       mouse_y = this._y;
  78.       dist_x = mouse_x - origin_x;
  79.       dist_y = mouse_y - origin_y;
  80.       if(Number(dist_x) < 0)
  81.       {
  82.          normalise = -1 * dist_x;
  83.       }
  84.       else
  85.       {
  86.          normalise = dist_x;
  87.       }
  88.       if(Number(dist_y) < 0)
  89.       {
  90.          normalise = Number(normalise) + Number(-1 * dist_y);
  91.       }
  92.       else
  93.       {
  94.          normalise = Number(normalise) + Number(dist_y);
  95.       }
  96.       if(Number(dist_x) >= 0 and Number(dist_y) >= 0)
  97.       {
  98.          direction = 90 * (dist_y / normalise);
  99.       }
  100.       else if(0 >= Number(dist_x) and Number(dist_y) >= 0)
  101.       {
  102.          direction = Number(-90 * (dist_x / normalise)) + 90;
  103.       }
  104.       else if(0 >= Number(dist_x) and 0 >= Number(dist_y))
  105.       {
  106.          direction = Number(-90 * (dist_y / normalise)) + 180;
  107.       }
  108.       else
  109.       {
  110.          direction = Number(90 * (dist_x / normalise)) + 270;
  111.       }
  112.       myYGravity = Math.sin(0.017453292519943295 * direction) * myGrav;
  113.       myXGravity = Math.cos(0.017453292519943295 * direction) * myGrav;
  114.       _parent.planetfinder._rotation = direction;
  115.    }
  116.    if(WinLose == "lose")
  117.    {
  118.       if(myFailTime)
  119.       {
  120.          if(getTimer() - myFailtime >= 5000)
  121.          {
  122.             myLanded = "stop";
  123.             _parent.popup.gotoAndStop("loser");
  124.          }
  125.       }
  126.       else
  127.       {
  128.          myFailtime = getTimer();
  129.          _root.Angry.go = "stop";
  130.       }
  131.    }
  132.    else if(WinLose == "win")
  133.    {
  134.       if(myWinTime)
  135.       {
  136.          if(getTimer() - myWinTime >= 2000)
  137.          {
  138.             myLanded = "stop";
  139.             _parent.popup.gotoAndStop("winner");
  140.          }
  141.       }
  142.       else
  143.       {
  144.          myWinTime = getTimer();
  145.          _root.Angry.go = "stop";
  146.       }
  147.    }
  148.    if(exploding == "true")
  149.    {
  150.       explode();
  151.       gravity();
  152.       constant();
  153.       myXMovement = 0;
  154.       myYMovement = 0;
  155.       WinLose = "lose";
  156.    }
  157.    if(myLanded == "go")
  158.    {
  159.       gravity();
  160.       constant();
  161.       if(key.isDown(38))
  162.       {
  163.          myVelocity = 0.2;
  164.          engineburn();
  165.          myXMovement = Math.cos(0.017453292519943295 * myRotation) * myVelocity;
  166.          myYMovement = Math.sin(0.017453292519943295 * myRotation) * myVelocity;
  167.       }
  168.       else
  169.       {
  170.          myXmovement = 0;
  171.          myYmovement = 0;
  172.       }
  173.       if(key.isDown(37))
  174.       {
  175.          rotate(-1);
  176.       }
  177.       if(key.isDown(39))
  178.       {
  179.          rotate(1);
  180.       }
  181.    }
  182.    else if(myLanded == "stop")
  183.    {
  184.       myXmovement = 0;
  185.       myYmovement = 0;
  186.       myXMomentum = 0;
  187.       myYMomentum = 0;
  188.    }
  189. }
  190.